<script type="text/javascript">

    function remove(id)
    {
        var fr = document.getElementById('cmtForm');
        var deletedCmt = document.getElementById('deletedCmt');
        deletedCmt.value = id;
        fr.submit();
    }
    
     var RecaptchaOptions = {
        theme : 'blackglass'
     };
</script>
<div id="post_content">
    <div id="content_title">

    </div>
    <div id="body_content">
        <h1><?php echo $news->title; ?></h1>

        <div id="body_content_detail">
            <?php echo html_entity_decode($news->detail,ENT_QUOTES,'UTF-8'); ?>
        </div>
        <br />
        <br/>
        <div id="comment_form" style="text-align:left; margin-left:50px;">
            <?php
             if(isset($cmt_list))
             {
                ?>
            <form action="<?php echo Utility::currentUrl(); ?>" method="post" id="cmtForm">
            <h2 style="font-weight:bold;color:#d2691e;">Bình luận : </h2>
                <?php
                $i = 1;
                $session = Session::getInstance();
                if($session->isExist('id'))
                {
                    foreach($cmt_list as $cmt)
                    {
                        ?>
                        <div class="comment-box">
                            <span style="color:black;font-weight:bolder;"> <?php echo $i;?> . <a href="mailto:<?php echo $cmt->author_email;?>"
                                                         style="color:black;font-weight:bold;"><?php echo $cmt->author_name; ?></a> : </span>
                            <span><a href="#" onclick="if (confirm('Bạn có chắc muốn xóa bình luận này ?')) remove(this.id);" title="Xóa bình luận" style="color:blue;" id="<?php echo $cmt->id;?>">[Xóa]</a> </span>
                            <p style="color:black;"><?php echo $cmt->detail;?></p>
                        </div>
                        <?php
                        $i++;
                    }
                }
                else
                {
                    foreach($cmt_list as $cmt)
                    {
                        ?>
                        <div class="comment-box">
                                    <span style="color:black;font-weight:bolder;"> <?php echo $i;?> . <a
                                        href="mailto:<?php echo $cmt->author_email;?>"
                                        style="color:black;font-weight:bold;"><?php echo $cmt->author_name; ?></a> : </span>

                            <p style="color:black;"><?php echo $cmt->detail;?></p>
                        </div>
                        <?php
                        $i++;
                    }
                }
                ?>
                <input type="hidden" name="deletedCmt" id="deletedCmt" value="" />
            </form>
                <?php
             }
            ?>
            <br /><br/>
            <?php
            if($news->comment_enable == 1)
            {
                ?>
            <h2 style="font-weight:bold;color:#d2691e;">Viết bình luận : </h2>
            <?php
            if(isset($errorMessage))
            {
                ?>
            <ul>
                <?php
                foreach($errorMessage as $error)
                {
                    echo "<li style='color:black;font-weight:bold;'>$error</li>";
                }
                ?>
            </ul>
            <?php
            }

            if(isset($cmt_ok))
            {
                ?>
            <span style="color:red;font-weight:bolder;"><?php echo $cmt_ok; ?></span>
            <?php
            }
             ?>
            <form id="cmt_form" action="<?php echo Utility::currentUrl();?>" method="post">
                <table>
                    <tr>
                        <td>
                            <label style="color:black;font-weight:bold;">Tên người viết : </label><br/>
                            <input type="text" name="author_name"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label style="color:black;font-weight:bold;">Email : </label><br/>
                            <input type="text" name="author_email"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label style="color:black;font-weight:bold;">Nội dung</label><br/>
                            <textarea rows="8" cols="50" name="detail"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label style="color:black;font-weight:bold;">Mã kiểm tra</label>
                            <div>
                            <?php
                                global $public_key;
                                echo recaptcha_get_html($public_key);
                            ?>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="hidden" name="post_id" value="<?php echo $news->id; ?>"/>
                            <input type="submit" name="send" value="Gửi bình luận"/>
                            <input type="reset" value="Viết lại"/>
                        </td>
                    </tr>
                </table>
            </form>
                <?php
            }
            else
            {
                ?>
            <h2 style="font-weight:bold;color:#8b0000;">Chức năng bình luận đã bị khóa </h2>
                <?php
            }
            ?>
            
        </div>
    </div>
    <div id="foot_content">
        <div id="next">
            <a href="#"><?php echo $news->p_date; ?></a>
        </div>
    </div>
</div>